package kamikaze.entity;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@Entity
public class Order implements Serializable {

	private static final long serialVersionUID = 1L;

	public enum PaymentStatus {
		SUCCESFUL, FAILED, REJECTED
	};

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Long id;

	private long userId;
	private String description;
	private BigDecimal totalPrice;

	private PaymentStatus status;
	@Temporal(TemporalType.TIMESTAMP)
	private Date date = new Date();

	@OneToMany(cascade = CascadeType.ALL)
	private List<OrderItem> itemList = new LinkedList<OrderItem>();

	public List<OrderItem> getItemList() {
		return itemList;
	}

	public void addItem(OrderItem item) {
		itemList.add(item);
	}

	public Date getDate() {
		return date;
	}

	public String getDescription() {
		return description;
	}

	public BigDecimal getTotalPrice() {
		return totalPrice;
	}

	public long getUserId() {
		return userId;
	}

	public void setTotalPrice(BigDecimal totalPrice) {
		this.totalPrice = totalPrice;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public void setUserId(long userId) {
		this.userId = userId;
	}

	public Long getId() {
		return id;
	}

	public PaymentStatus getStatus() {
		return status;
	}

	public void setStatus(PaymentStatus status) {
		this.status = status;
	}
}
